package com.jd.nbd.strategy05;

/**
 * Created by liyue on 2017/8/24
 */
public class Context {
  private Rule[] ruleList;

  public Context(Rule[] ruleList) {
    this.ruleList = ruleList;
  }

  public Context() {
  }

  public Rule[] getRuleList() {
    return ruleList;
  }

  public void setRuleList(Rule[] ruleList) {
    this.ruleList = ruleList;
  }

  public boolean doValidate(Person person) {
    if (ruleList != null && ruleList.length > 0) {
      for (Rule rule: ruleList) {
        if(!rule.doValidate(person)){
          return false;
        }
      }
    }
    return true;
  }
}
